import request from "@/router/axios";

export const getList = (page, size, params) => {
  return request({
    url: "/base/goodsManage/list",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};
//违规下架
export const unRulesDown = (id,goodsStatus) => {
    return request({
        url: "/base/goodsManage/shelves",
        method: "post",
        params: {
            id,
            goodsStatus
        }
    });
};
export const getGoodsList = (page, size, params) => {
  return request({
    url: "/base/brand/list",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};
export const getClassList = (page, size, params) => {
  return request({
    url: "/base/goodsClass/listTree",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};
export const remove = id => {
  return request({
    url: "/base/goodsManage/delete",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      id
    }
  });
};

export const add = row => {
  return request({
    url: "/base/goodsManage/add",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: row
  });
};

export const update = row => {
  return request({
    url: "/base/goodsManage/editItem",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: row
  });
};

export const changeStatus = (userId, status) => {
  return request({
    url: "/base/goodsManage/changeStatus",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      userId,
      status
    }
  });
};

export const updateDisplay = (id, goodsRecommend) => {
  // 这里classDisplay如果是boolean类型,无法传入后台,待以后优化吧
  return request({
    url: "/base/goodsManage/editItem",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      id,
        goodsRecommend
    }
  });
};
export const getGoodsClassAll = () => {
  return request({
    url: "/base/goodsClass/classData",
    method: "post"
  });
};
//根据商品ID返回商品
export const getGoodsListByIds = data => {
  return request({
    url: "base/sellerGoods/getGoodsListByIds",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: data
  });
};

//获取商品列表，线下店配货页面使用
export const getListForOffLineStore = (page, size, params) => {
  return request({
    url: "/base/goodsManage/list",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};
//获取商品销量等信息
export const showGoodsStock = (goodsId) => {
  return request({
    url: "/base/goodsManage/showGoodsStock",
    method: "post",
	meta: {
	  isSerialize: true
	},
   data:{
	   goodsId
   }
  });
};
//修改商品销量
export const editGoodsStock = (data) => {
  return request({
    url: "/base/goodsManage/editGoodsStock",
    method: "post",
	meta: {
	  isSerialize: true
	},
   data:data
  });
};

export const getUpload = () => {
  return request({
    url: 'base/homeGoods/list',
    method: 'post',
  })
}

export const  setUpload= (params) => {
  return request({
    url: 'base/homeGoods/addItem',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data:params
  })
}
export const  getGoodsSoRangeStr= (data) => {
  return request({
    url: 'base/organization/getGoodsSoRangeStr',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data:data
  })
}


export const  deleteHomeGoods= (homeGoodsSeq) => {
  return request({
    url: 'base/homeGoods/delete',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data:{
      homeGoodsSeq
    }
  })
}
export const  getOrganizationTreeNodeByIds= (ids) => {
  return request({
    url: '/base/organization/getOrganizationTreeNodeByIds',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data:{
      ids
    }
  })
}